package com.imooc.order.message;

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

import com.imooc.order.dto.OrderDTO;

import lombok.extern.slf4j.Slf4j;

@Component
@EnableBinding(StreamClient.class)
@Slf4j
public class StreamReceiver {

	/*@StreamListener(StreamClient.INPUT)
	public void process(String message) {
		log.info("StreamReceiver : {}", message);
	}*/
	
	@StreamListener(StreamClient.INPUT)
	@SendTo(StreamClient.ORDER_RS_OUTPUT)
	public String process(OrderDTO message) {
		log.info("StreamReceiver : {}", message);
		return "received..........";
	}
	
	@StreamListener(StreamClient.ORDER_RS_INPUT)
	public void handleRs(String message) {
		log.info("StreamReceiver rs : {}", message);
	}
}
